-
-
Notifications
You must be signed in to change notification settings - Fork 241
fix(router): query params not being saved #2062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(router): query params not being saved #2062
Conversation
After some testing, I believe this is ready for review (e2e changes need to be reverted before merge) |
test |
causes issues with `npm install`
const isNewPage = outlet.states.length === 0; | ||
const lastState = outlet.states[outlet.states.length - 1]; | ||
const equalStateUrls = outlet.containsTopState(currentSegmentGroup.toString()); | ||
|
||
const locationState: LocationState = { | ||
segmentGroup: currentSegmentGroup, | ||
isRootSegmentGroup: false, | ||
isPageNavigation: isNewPage | ||
isPageNavigation: isNewPage, | ||
queryParams: {...queryParams} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be best to use some protection here in case queryParams comes in null or undefined?
queryParams: { ...(queryParams || {}) }
const pathByOutlets = this.getPathByOutlets(segmentGroup); | ||
const newOutlet = new Outlet(outletKey, path, pathByOutlets, modalNavigation); | ||
|
||
const locationState: LocationState = { | ||
segmentGroup: segmentGroup, | ||
isRootSegmentGroup: false, | ||
isPageNavigation: true // It is a new OutletNode. | ||
isPageNavigation: true, // It is a new OutletNode. | ||
queryParams: {...queryParams} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
queryParams: { ...(queryParams || {}) }
Thank you for the contribution @edusperoni 👍 |
PR Checklist
What is the current behavior?
Query parameters are not preserved when navigating back.
The router state consists only of
UrlSegmentGroup
, which does not store any query parameters.What is the new behavior?
The state now stores the QueryParams and properly restores them.
Fixes #1509.
Please ignore the tests I've done in e2e, I'll remove them when work is done.
Tests are passing, additional tests needed for modal and params preservation
Possible alternative:
store
queryParams[]
inNSLocationStrategy
(since the outlet itself does not have queryParams, but the page does) and push to it at everypushState
and pop at everypopState
, but how would it work with replaceState?